import type {
  AjaxPagingResult,
} from '@/types'
import type { RemoteMonitoringParams, RemoteMonitoringResult } from '@/types/modules/api-remoteMonitoring​'

const controller = getAjaxBaseUrl(
  '/remoteMonitoring',
  '/energy',
)

/** 导出远程监控信息 */
export async function exportRemoteMonitoring(params: Partial<RemoteMonitoringParams>) {
  const { data } = await request({
    method: 'POST',
    url: `${controller}/exportRemoteMonitoring`,
    responseType: 'blob',
    data: params,
  })

  try {
    if (data.code) {
      ElMessage.error(data.msg)
      return
    }
  }
  catch (e) {}

  downloadByA(
    URL.createObjectURL(data),
    '远程抄表',
  )
}

export async function exportRemoteMonitoring1(params: Partial<RemoteMonitoringParams>) {
  return post(`${controller}/export`, params)
}

/** 分页查询远程监控信息列表 */
export function selectRemoteMonitoringPage(params: Partial<RemoteMonitoringParams>) {
  return post<AjaxPagingResult<RemoteMonitoringResult[]>>(
    `${controller}/selectRemoteMonitoringPage`,
    params,
  )
}

export function loadRemoteMonitoringList(data: Partial<RemoteMonitoringParams>) {
  return post(
    `${controller}/loadRemoteMonitoringList`,
    data,
  )
}

export function queryParamList(energyCode: string) {
  return get(`${controller}/param/setting/${energyCode}`)
}
